#ifndef APP_LIGHTING_HPP_
#define APP_LIGHTING_HPP_

#include <device/aerProgram.hpp>
#include <device/aerTexture.hpp>
#include <device/aerFrameBuffer.hpp>
#include <device/aerDeviceBuffer.hpp>
#include <misc/aerShape.hpp>

#include "Data.hpp"


///
/// Handles the lighting rendering
///
class Lighting
{
  private:
    struct ShadowmapPass
    {
      //
    };
    
    struct AccumulationPass
    {
      int width, height;
      aer::Texture color;
      aer::FrameBuffer framebuffer;
    };
    
    
    struct DirLight
    {
      aer::Program accumProgram;
    };
    
    struct OmniLight
    {
      //std::vector<Light> lights;
      
      aer::Program      accumProgram; // instanciate sphere lights
      aer::DeviceBuffer positionTB;   // [float4] RGB position + A radius
      aer::DeviceBuffer colorTB;      // [float4] RGB color + A (empty)
      aer::SphereRaw    mesh;
    };
    
    struct SpotLight
    {
      //
    };
    
    
  public://
    ShadowmapPass    shadowmapPass;
    AccumulationPass accumulationPass;
  
  private:
    DirLight  m_dirLight;
    OmniLight m_omniLight;
    

  public:
    ~Lighting() {release();}
    
    void init();
    void release();
    
    void resize( const int width, const int height);
    
    void applyShadowmap();
    void applyAccumulation( Data& data, aer::Texture *pNormalBuffer, aer::Texture *pDepthBuffer);
};

#endif //APP_LIGHTING_HPP_
